<script type="text/javascript">
/*!
 * Ext JS Library 3.3.0
 * Copyright(c) 2006-2010 Ext JS, Inc.
 * licensing@extjs.com
 * http://www.extjs.com/license
 */
Ext.onReady(function(){
    Ext.QuickTips.init();

    // NOTE: This is an example showing simple state management. During development,
    // it is generally best to disable state management as dynamically-generated ids
    // can change across page loads, leading to unpredictable results.  The developer
    // should ensure that stable state ids are set for stateful components in real apps.    
    Ext.state.Manager.setProvider(new Ext.state.CookieProvider());

    var httpProxy = new Ext.data.HttpProxy({url:"<%=Yii::app()->createUrl('post/admin', array('ext' => 1));%>"});

    var employee = new Ext.data.Record.create([
        {name:'title',type:'string'},
        {name:'add_time',type:'datatime'},
    ]);
    var reader = new Ext.data.JsonReader({
        totalProperty:"total",
        root:"rows"
    }, employee);

    var store = new Ext.data.Store({
        proxy:httpProxy,
        reader:reader,
        baseParams:{
            limit: 10,
            start: 0
        }
    });
    
    var pageToolbar = new Ext.PagingToolbar({
        store:store,
        pageSize:10
    });

    store.load();

    // create the Grid
    var grid = new Ext.grid.GridPanel({
        store: store,
        columns: [
            {header:"标题", dataIndex:'title', width:200},
            {header:"添加时间", dataIndex:'add_time', width:120}
        ],
        height: 350,
        width: 600,
        title: 'Array Grid',
        bbar:pageToolbar
    });

    // render the grid to the specified div in the page
    grid.render('grid-example');
});
</script>
<div id="grid-example"></div>
